package com.logic.modular.game.player.hero.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.comment.pojo.domain.logic.domain.PlayerHero;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 游戏账户武将数据(PlayerHero)表数据库访问层
 *
 * @author cxy
 * @since 2024-07-29 14:41:14
 */
public interface PlayerHeroMapper extends BaseMapper<PlayerHero> {

    @Override
    default int updateById(PlayerHero entity) {
        LambdaQueryWrapper<PlayerHero> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PlayerHero::getUid, entity.getUid());
        wrapper.eq(PlayerHero::getCoreHeroId, entity.getCoreHeroId());
        return this.update(entity, wrapper);
    }

    @Select("select count(1) from player_hero where uid = #{uid} and level = #{level}")
    long countMaxLevelHero(@Param("uid") Long playerId, @Param("level") Integer heroMaxLevel);

    @Select("select count(1) from player_hero where uid = #{uid} and star = #{star}")
    long countMaxStarHero(@Param("uid") Long playerId, @Param("star") Integer heroMaxStar);

    @Select("select count(1) from player_hero where uid = #{uid} and quality = #{quality}")
    long countMaxQualityHero(Long playerId, Integer heroMaxQualityLv);
}

